<!--

    Copyright © 2016-2024 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<ng-container [formGroup]="sliderWidgetConfigForm">
  <tb-target-device formControlName="targetDevice"></tb-target-device>
  <div class="tb-form-panel">
    <div class="tb-form-panel-title" translate>widgets.slider.behavior</div>
    <div class="tb-form-row">
      <div class="fixed-title-width" tb-hint-tooltip-icon="{{'widgets.slider.initial-value-hint' | translate}}" translate>widgets.slider.initial-value</div>
      <tb-get-value-action-settings fxFlex
                                    panelTitle="widgets.slider.initial-value"
                                    [valueType]="valueType.DOUBLE"
                                    [aliasController]="aliasController"
                                    [targetDevice]="targetDevice"
                                    [widgetType]="widgetType"
                                    formControlName="initialState"></tb-get-value-action-settings>
    </div>
    <div class="tb-form-row space-between">
      <div class="fixed-title-width" tb-hint-tooltip-icon="{{'widgets.slider.on-value-change-hint' | translate}}" translate>widgets.slider.on-value-change</div>
      <tb-set-value-action-settings fxFlex
                                    panelTitle="widgets.slider.on-value-change"
                                    [valueType]="valueType.DOUBLE"
                                    [aliasController]="aliasController"
                                    [targetDevice]="targetDevice"
                                    [widgetType]="widgetType"
                                    formControlName="valueChange"></tb-set-value-action-settings>
    </div>
    <div class="tb-form-row">
      <div class="fixed-title-width" tb-hint-tooltip-icon="{{'widgets.rpc-state.disabled-state-hint' | translate}}" translate>widgets.rpc-state.disabled-state</div>
      <tb-get-value-action-settings fxFlex
                                    panelTitle="widgets.rpc-state.disabled-state"
                                    [valueType]="valueType.BOOLEAN"
                                    stateLabel="widgets.rpc-state.disabled"
                                    [aliasController]="aliasController"
                                    [targetDevice]="targetDevice"
                                    [widgetType]="widgetType"
                                    formControlName="disabledState"></tb-get-value-action-settings>
    </div>
  </div>
  <div class="tb-form-panel">
    <div class="tb-form-panel-title" translate>widget-config.appearance</div>
    <tb-image-cards-select rowHeight="2:1"
                           [cols]="{columns: 3,
                                    breakpoints: {
                                      'lt-sm': 1,
                                      'lt-md': 2
                                    }}"
                           label="{{ 'widgets.slider.layout' | translate }}" formControlName="layout">
      <tb-image-cards-select-option *ngFor="let layout of sliderLayouts"
                                    [value]="layout"
                                    [image]="sliderLayoutImageMap.get(layout)">
        {{ sliderLayoutTranslationMap.get(layout) | translate }}
      </tb-image-cards-select-option>
    </tb-image-cards-select>
    <div class="tb-form-row">
      <mat-slide-toggle class="mat-slide" formControlName="autoScale">
        {{ 'widgets.slider.auto-scale' | translate }}
      </mat-slide-toggle>
    </div>
    <div class="tb-form-row column-xs">
      <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showTitle">
        {{ 'widget-config.title' | translate }}
      </mat-slide-toggle>
      <div fxFlex fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
        <mat-form-field class="flex" appearance="outline" subscriptSizing="dynamic">
          <input matInput formControlName="title" placeholder="{{ 'widget-config.set' | translate }}">
        </mat-form-field>
        <tb-font-settings formControlName="titleFont"
                          clearButton
                          [previewText]="sliderWidgetConfigForm.get('title').value"
                          [initialPreviewStyle]="widgetConfig.config.titleStyle">
        </tb-font-settings>
        <tb-color-input asBoxInput
                        colorClearButton
                        formControlName="titleColor">
        </tb-color-input>
      </div>
    </div>
    <div class="tb-form-row column-xs">
      <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showIcon">
        {{ 'widgets.slider.icon' | translate }}
      </mat-slide-toggle>
      <div fxFlex fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
        <mat-form-field appearance="outline" class="flex number" subscriptSizing="dynamic">
          <input matInput type="number" min="0" formControlName="iconSize" placeholder="{{ 'widget-config.set' | translate }}">
        </mat-form-field>
        <tb-css-unit-select fxFlex formControlName="iconSizeUnit"></tb-css-unit-select>
        <tb-material-icon-select asBoxInput
                                 iconClearButton
                                 [color]="sliderWidgetConfigForm.get('iconColor').value"
                                 formControlName="icon">
        </tb-material-icon-select>
        <tb-color-input asBoxInput
                        colorClearButton
                        formControlName="iconColor">
        </tb-color-input>
      </div>
    </div>
    <div *ngIf="sliderWidgetConfigForm.get('layout').value !== sliderLayout.simplified" class="tb-form-row column-xs">
      <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showValue">
        {{ 'widgets.slider.value' | translate }}
      </mat-slide-toggle>
      <div fxFlex fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
        <tb-unit-input class="flex" formControlName="valueUnits"></tb-unit-input>
        <mat-form-field appearance="outline" class="flex number" subscriptSizing="dynamic">
          <input matInput formControlName="valueDecimals" type="number" min="0" max="15" step="1" placeholder="{{ 'widget-config.set' | translate }}">
          <div matSuffix fxHide.lt-md translate>widget-config.decimals-suffix</div>
        </mat-form-field>
        <tb-font-settings formControlName="valueFont"
                          [previewText]="valuePreviewFn">
        </tb-font-settings>
        <tb-color-input asBoxInput
                        colorClearButton
                        formControlName="valueColor">
        </tb-color-input>
      </div>
    </div>
    <div class="tb-form-row space-between column-xs">
      <div>{{ 'widgets.slider.range' | translate }}</div>
      <div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
        <div class="tb-small-label" translate>widgets.slider.min</div>
        <mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
          <input matInput formControlName="tickMin" type="number" placeholder="{{ 'widget-config.set' | translate }}">
        </mat-form-field>
        <div class="tb-small-label" translate>widgets.slider.max</div>
        <mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
          <input matInput formControlName="tickMax" type="number" placeholder="{{ 'widget-config.set' | translate }}">
        </mat-form-field>
      </div>
    </div>
    <div class="tb-form-row space-between">
      <mat-slide-toggle class="mat-slide" formControlName="showTicks">
        {{ 'widgets.slider.range-ticks' | translate }}
      </mat-slide-toggle>
      <div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
        <tb-font-settings formControlName="ticksFont"
                          previewText="100">
        </tb-font-settings>
        <tb-color-input asBoxInput
                        colorClearButton
                        formControlName="ticksColor">
        </tb-color-input>
      </div>
    </div>
    <div class="tb-form-row space-between">
      <mat-slide-toggle class="mat-slide" formControlName="showTickMarks">
        {{ 'widgets.slider.tick-marks' | translate }}
      </mat-slide-toggle>
      <div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
        <mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
          <input matInput formControlName="tickMarksCount" type="number" min="2"
                 step="1" placeholder="{{ 'widget-config.set' | translate }}">
        </mat-form-field>
        <tb-color-input asBoxInput
                        formControlName="tickMarksColor">
        </tb-color-input>
      </div>
    </div>
    <div class="tb-form-row space-between column-xs">
      <div>{{ 'widgets.slider.colors' | translate }}</div>
      <div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="12px">
        <div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
          <div translate>widgets.slider.main</div>
          <tb-color-input asBoxInput
                          formControlName="mainColor">
          </tb-color-input>
        </div>
        <mat-divider vertical></mat-divider>
        <div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
          <div translate>widgets.slider.background</div>
          <tb-color-input asBoxInput
                          formControlName="backgroundColor">
          </tb-color-input>
        </div>
      </div>
    </div>
    <div class="tb-form-row space-between column-xs">
      <div>{{ 'widgets.rpc-state.disabled-state' | translate }}</div>
      <div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="12px">
        <div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
          <div translate>widgets.slider.main</div>
          <tb-color-input asBoxInput
                          formControlName="mainColorDisabled">
          </tb-color-input>
        </div>
        <mat-divider vertical></mat-divider>
        <div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
          <div translate>widgets.slider.background</div>
          <tb-color-input asBoxInput
                          formControlName="backgroundColorDisabled">
          </tb-color-input>
        </div>
      </div>
    </div>
    <div *ngIf="sliderWidgetConfigForm.get('layout').value === sliderLayout.extended"
         class="tb-form-row column-xs">
      <div class="fixed-title-width">
        {{ 'widgets.slider.left-icon' | translate }}
      </div>
      <div fxFlex fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
        <mat-form-field appearance="outline" class="flex number" subscriptSizing="dynamic">
          <input matInput type="number" min="0" formControlName="leftIconSize" placeholder="{{ 'widget-config.set' | translate }}">
        </mat-form-field>
        <tb-css-unit-select fxFlex formControlName="leftIconSizeUnit"></tb-css-unit-select>
        <tb-material-icon-select asBoxInput
                                 [color]="sliderWidgetConfigForm.get('leftIconColor').value"
                                 formControlName="leftIcon">
        </tb-material-icon-select>
        <tb-color-input asBoxInput
                        formControlName="leftIconColor">
        </tb-color-input>
      </div>
    </div>
    <div *ngIf="sliderWidgetConfigForm.get('layout').value === sliderLayout.extended"
         class="tb-form-row column-xs">
      <div class="fixed-title-width">
        {{ 'widgets.slider.right-icon' | translate }}
      </div>
      <div fxFlex fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
        <mat-form-field appearance="outline" class="flex number" subscriptSizing="dynamic">
          <input matInput type="number" min="0" formControlName="rightIconSize" placeholder="{{ 'widget-config.set' | translate }}">
        </mat-form-field>
        <tb-css-unit-select fxFlex formControlName="rightIconSizeUnit"></tb-css-unit-select>
        <tb-material-icon-select asBoxInput
                                 [color]="sliderWidgetConfigForm.get('rightIconColor').value"
                                 formControlName="rightIcon">
        </tb-material-icon-select>
        <tb-color-input asBoxInput
                        formControlName="rightIconColor">
        </tb-color-input>
      </div>
    </div>
  </div>
  <div class="tb-form-panel">
    <div class="tb-form-panel-title" translate>widget-config.card-appearance</div>
    <div class="tb-form-row space-between">
      <div>{{ 'widgets.background.background' | translate }}</div>
      <tb-background-settings formControlName="background">
      </tb-background-settings>
    </div>
    <div class="tb-form-row space-between column-lt-md">
      <div translate>widget-config.show-card-buttons</div>
      <mat-chip-listbox multiple formControlName="cardButtons">
        <mat-chip-option value="fullscreen">{{ 'fullscreen.fullscreen' | translate }}</mat-chip-option>
      </mat-chip-listbox>
    </div>
    <div class="tb-form-row space-between">
      <div>{{ 'widget-config.card-border-radius' | translate }}</div>
      <mat-form-field appearance="outline" subscriptSizing="dynamic">
        <input matInput formControlName="borderRadius" placeholder="{{ 'widget-config.set' | translate }}">
      </mat-form-field>
    </div>
  </div>
  <tb-widget-actions-panel
      formControlName="actions">
  </tb-widget-actions-panel>
</ng-container>
